From 9b1b2ebb25d51ee070ad4978f4e58028079705b5 Mon Sep 17 00:00:00 2001 From: Liangent Date: Tue, 24 Oct 2017 21:29:57 +0000 Subject: [PATCH] mw.widgets.DateInputWidget: Fix unexpected MMMMM or ddddd date format In some locale data in moment.js such as zh, llll date format already uses MMMM and dddd. The original attempt to expand MMM to MMMM and ddd to dddd inadvertently expands MMMM to MMMMM and dddd to ddddd, which is then interpreted as MMMM or dddd followed by an unexpected single M or d. Change-Id: I2634dfbaaf9615a13dce7b8f4ba3c3bea6863a91 --- resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js index f10c93db48..9d2e93b8cf 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js @@ -465,7 +465,8 @@ format = llll.replace( lll.replace( ll, '' ), '' ); if ( this.longDisplayFormat ) { - format = format.replace( 'MMM', 'MMMM' ).replace( 'ddd', 'dddd' ); + // Replace MMM to MMMM and ddd to dddd but don't change MMMM and dddd + format = format.replace( /MMMM?/, 'MMMM' ).replace( /dddd?/, 'dddd' ); } return format; -- 2.20.1